package zengyan.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

/**
 * Created by ZengYan on 2016/3/27.
 */
public class ToolBar extends LinearLayout{
    private Button rightBtn,leftBtn;
    private ImageView centorLogo;
    private int cCount,touming=0x003F51B5;

    public ToolBar(Context context) {
        super(context,null);
    }

    public ToolBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        cCount=this.getChildCount();
        initViews();
    }

    private void initViews( ) {
        Log.d("ToolBar", "intiView!!!");
//        for (int i = 0; i < cCount; i++) {
//            View view = getChildAt(i);
//            if (view instanceof EditText) {
//                mEdit = (EditText) view;
//            }
//            if (view instanceof AnimCheckBox) {
//                mCheckBox = (AnimCheckBox) view;
//            }
//        }
        rightBtn = (Button) getChildAt(0);
        centorLogo= (ImageView) getChildAt(1);
        leftBtn = (Button) getChildAt(2);
        rightBtn.setBackgroundColor(touming);
        centorLogo.setBackgroundColor(touming);
        leftBtn.setBackgroundColor(touming);
    }

    public void setRightBtnOnClickListener(OnClickListener listener){
        rightBtn.setOnClickListener(listener);
    }
    public void setLeftBtnOnClickListener(OnClickListener listener){
        leftBtn.setOnClickListener(listener);

    }
    public void removeRightBtn(){
        rightBtn.setBackground(null);
    }
    public void removeLeftBtn(){
        leftBtn.setBackground(null);
    }

    public void setRightBtnImage(Drawable drawable){
        rightBtn.setBackground(drawable);
    }
    public void setLeftBtnImage(Drawable drawable){
        leftBtn.setBackground(drawable);
    }



}
